package com.nagarro.assignment1.factory;

import com.nagarro.assignment1.helper.Constants.TypeOfItem;
import com.nagarro.assignment1.inventory.*;

/**
 * A factory class which creates and returns appropriate Item object.
 * 
 * @author Shreyasi Agrawal
 * @version 1.0 {@link Item} {@link Raw} {@link Manufactured} {@link Imported}
 */
public class ItemFactory {

	/**
	 * Method to create Item type according to the parameter type
	 * 
	 * @param type
	 *            Type of Item object required
	 * @return The Item object
	 */
	public Item getItem(String type) {
		Item itemObject = null;

		// create object according to type of item
		switch (TypeOfItem.valueOf(type.toUpperCase())) {
		case RAW:
			itemObject = new Raw();
			break;
		case MANUFACTURED:
			itemObject = new Manufactured();
			break;
		default:
			itemObject = new Imported();
			break;
		}
		return itemObject;
	}
}